package project.adapter;

import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

import project.model.PrProject;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import approve.action.R;

public class Projectlist_adapter_tc extends BaseAdapter implements OnClickListener {

	private Context context;
	private List<PrProject> listProject;
	String from,to;
	
	public Projectlist_adapter_tc(Context context,List<PrProject> listProject,String from,String to){
		this.context=context;
		this.listProject=listProject;
		this.from=from;
		this.to=to;
	}
	
	public int getCount() {
		// TODO Auto-generated method stub
		return listProject.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listProject.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		PrProject entry=listProject.get(position);
		if(convertView==null){
			LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView=inflater.inflate(R.layout.listerror_row, null);
		}
		DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		TextView tvTitleError=(TextView)convertView.findViewById(R.id.titleError);
		tvTitleError.setText(entry.getNameProject());
		TextView tvPhone = (TextView) convertView.findViewById(R.id.tvMobile);
		tvPhone.setText(entry.getNameManager()+" - "+ from+": "+format.format(entry.getDateStart())+" - "+ to+": "+format.format(entry.getDateComplete()));
		return convertView;
	}

	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		
	}

}
